package epin.fujiajun.sort.merge;

import epin.fujiajun.data.Array;
import epin.fujiajun.data.array.Number;

/**
 * Created by DELL on 2017/8/29.
 */
public class TopToDown extends Original {

    @Override
    public void sort(Array[] a) {
        int N = a.length;
        super.aux = new Array[N];
        sort(a, 0, N - 1);
    }

    private void sort(Array[] a, int low, int high){
        if (low < high){
            int middle = low + (high - low) / 2;
            sort(a, low, middle);
            sort(a, middle + 1, high);
            super.merge(a, low, middle, high);
        }
    }


    public static void main(String[] args){
        new TopToDown().main(Number.createArray(100, 1000));
    }
}
